﻿var status = 0;
var choice;
var scrolls = Array( 
Array("", 1472800, 0),
Array("", 1462106, 0),
Array("", 1462107, 0),
Array("", 1462108, 0),
Array("", 1462109, 0),
Array("", 1462110, 0),
Array("", 1462111, 0),
Array("", 1462112, 0),
Array("", 1462113, 0),
Array("", 1462114, 0),
Array("", 1462116, 0),
Array("", 1462118, 0),
Array("", 1462119, 0),
Array("", 1462120, 0),
Array("", 1462121, 0),
Array("", 1462122, 0),
Array("", 1462123, 0),
Array("", 1462124, 0),
Array("", 1462125, 0),
Array("", 1462126, 0),
Array("", 1462127, 0),
Array("", 1462128, 0),
Array("", 1462129, 0),
Array("", 1462130, 0),
Array("", 1462131, 0),
Array("", 1462132, 0),
Array("", 1462133, 0),
Array("", 1462134, 0),
Array("", 1462135, 0),
Array("", 1462136, 0),
Array("", 1462137, 0),
Array("", 1462138, 0),
Array("", 1462139, 0),
Array("", 1462141, 0),
Array("", 1462142, 0),
Array("", 1462143, 0),
Array("", 1462144, 0),
Array("", 1462145, 0),
Array("", 1462146, 0),
Array("", 1462152, 0),
Array("", 1462153, 0),
Array("", 1462155, 0),
Array("", 1462156, 0),
Array("", 1462157, 0),
Array("", 1462158, 0),
Array("", 1462159, 0),
Array("", 1462160, 0),
Array("", 1462162, 0),
Array("", 1462163, 0),
Array("", 1462176, 0),
Array("", 1462177, 0),
Array("", 1462178, 0),
Array("", 1462179, 0),
Array("", 1462180, 0),
Array("", 1462184, 0),
Array("", 1472000, 0),
Array("", 1472001, 0),
Array("", 1472002, 0),
Array("", 1472003, 0),
Array("", 1472004, 0),
Array("", 1472005, 0),
Array("", 1472006, 0),
Array("", 1472007, 0),
Array("", 1472008, 0),
Array("", 1472009, 0),
Array("", 1472010, 0),
Array("", 1472011, 0),
Array("", 1472012, 0),
Array("", 1472013, 0),
Array("", 1472014, 0),
Array("", 1472015, 0),
Array("", 1472016, 0),
Array("", 1472017, 0),
Array("", 1472018, 0),
Array("", 1472019, 0),
Array("", 1472020, 0),
Array("", 1472021, 0),
Array("", 1472022, 0),
Array("", 1472023, 0),
Array("", 1472024, 0),
Array("", 1472025, 0),
Array("", 1472026, 0),
Array("", 1472027, 0),
Array("", 1472028, 0),
Array("", 1472029, 0),
Array("", 1472030, 0),
Array("", 1472031, 0),
Array("", 1472032, 0),
Array("", 1472033, 0),
Array("", 1472034, 0),
Array("", 1472035, 0),
Array("", 1472036, 0),
Array("", 1472037, 0),
Array("", 1472038, 0),
Array("", 1472039, 0),
Array("", 1472040, 0),
Array("", 1472041, 0),
Array("", 1472042, 0),
Array("", 1472043, 0),
Array("", 1472045, 0),
Array("", 1472046, 0),
Array("", 1472047, 0),
Array("", 1472048, 0),
Array("", 1472049, 0),
Array("", 1472051, 0),
Array("", 1472052, 0),
Array("", 1472053, 0),
Array("", 1472054, 0),
Array("", 1472055, 0),
Array("", 1472056, 0),
Array("", 1472058, 0),
Array("", 1472059, 0),
Array("", 1472060, 0),
Array("", 1472061, 0),
Array("", 1472063, 0),
Array("", 1472068, 0),
Array("", 1472069, 0),
Array("", 1472071, 0),
Array("", 1472072, 0),
Array("", 1472077, 0),
Array("", 1472078, 0),
Array("", 1472079, 0),
Array("", 1472081, 0),
Array("", 1472083, 0),
Array("", 1472084, 0),
Array("", 1472086, 0),
Array("", 1472088, 0),
Array("", 1472089, 0),
Array("", 1472093, 0),
Array("", 1472094, 0),
Array("", 1472095, 0),
Array("", 1472100, 0),
Array("", 1472101, 0),
Array("", 1472102, 0),
Array("", 1472103, 0),
Array("", 1472104, 0),
Array("", 1472107, 0),
Array("", 1472110, 0),
Array("", 1472111, 0),
Array("", 1472112, 0),
Array("", 1472113, 0),
Array("", 1472114, 0),
Array("", 1472115, 0),
Array("", 1472116, 0),
Array("", 1472117, 0),
Array("", 1472118, 0),
Array("", 1472119, 0),
Array("", 1472120, 0),
Array("", 1472121, 0),
Array("", 1472122, 0),
Array("", 1472123, 0),
Array("", 1472124, 0),
Array("", 1472125, 0),
Array("", 1472126, 0),
Array("", 1472127, 0),
Array("", 1472128, 0),
Array("", 1472129, 0),
Array("", 1472130, 0),
Array("", 1472131, 0),
Array("", 1472132, 0),
Array("", 1472133, 0),
Array("", 1472134, 0),
Array("", 1472135, 0),
Array("", 1472136, 0),
Array("", 1472137, 0),
Array("", 1472139, 0),
Array("", 1472141, 0),
Array("", 1472142, 0),
Array("", 1472143, 0),
Array("", 1472144, 0),
Array("", 1472145, 0),
Array("", 1472146, 0),
Array("", 1472147, 0),
Array("", 1472148, 0),
Array("", 1472149, 0),
Array("", 1472150, 0),
Array("", 1472151, 0),
Array("", 1472152, 0),
Array("", 1472153, 0),
Array("", 1472154, 0),
Array("", 1472155, 0),
Array("", 1472156, 0),
Array("", 1472157, 0),
Array("", 1472158, 0),
Array("", 1472159, 0),
Array("", 1472160, 0),
Array("", 1472161, 0),
Array("", 1472163, 0),
Array("", 1472164, 0),
Array("", 1472165, 0),
Array("", 1472166, 0),
Array("", 1472167, 0),
Array("", 1472168, 0),
Array("", 1472174, 0),
Array("", 1472175, 0),
Array("", 1472177, 0),
Array("", 1472178, 0),
Array("", 1472179, 0),
Array("", 1472180, 0),
Array("", 1472182, 0),
Array("", 1472183, 0),
Array("", 1472197, 0),
Array("", 1472198, 0),
Array("", 1472199, 0),
Array("", 1472200, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到双头杖,灵魂手铳店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}